<template>
  <div class='friends-item'>
    <div class='player' :id='"link-"+link.id'>
      <div class='player-content' :style='link.isRecommend === 1 ? backgroundVip : backgroundCommon'>
        <span class='friend-tag' :style='link.isRecommend === 1? tagVip:tagCommon'>
          {{ websiteConfig.name }}的第{{ link.id }}号星辰
        </span>
        <div class='player-bg' v-if='link.isRecommend === 1'>
          <img src='https://cdn-oss.qiaoxiao.top/pic/heijinV.png' alt='推荐'>
<!--          <img src='https://npm.onmicrosoft.cn/hanyanzhi@1.0.1/heijinV.png' alt='推荐'>-->
        </div>
        <div class='album-cover' :style='link.isRecommend === 1 ? coverStyleVip:coverStyleCommon'>
          <a :href='link.linkAddress' target='_blank'>
            <img :src='link.linkAvatar' :alt='link.linkName' @error='handleErrorFriendAvatar'>
          </a>
        </div>
        <div class='play-controls-name'>
          <a :href='link.linkAddress' target='_blank'>
            <h4 class='friend-name' :style='link.isRecommend === 1? colorVip:colorCommon'>
              {{ link.linkName }}</h4>
          </a>
        </div>
        <div class='play-controls-time'>
          <span class='join-time' :style='link.isRecommend === 1? colorVip:colorCommon'>
            {{ link.createTime }}&nbsp;加入本站
          </span>
        </div>
        <div class='play-controls-introduction'>
          <span class='friend-desc' :style='link.isRecommend === 1? colorVip:colorCommon'>
            {{ link.linkIntro }}
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang='ts'>
import { computed, defineComponent, reactive, toRefs } from 'vue'
import { handleErrorFriendAvatar } from '@/utils/avatarUtil'
import { useAppStore } from '@/stores/app'

export default defineComponent({
  name: 'index',
  props: ['link'],
  setup() {
    const reactiveData = reactive({
      coverStyleCommon: 'box-shadow: 0 0 0 1px #146792',
      coverStyleVip: 'box-shadow: 0 0 0 1px #ffd38b',
      backgroundCommon: 'background:linear-gradient(317deg, #a14fd2, #8888fc 30%, #c6bcff)',
      backgroundVip: 'background:linear-gradient(25deg, #000000 10%, #383838 70%, #000000 100%)',
      colorCommon: 'color: #ffffff',
      colorVip: 'color: #faad14',
      tagVip: 'background: linear-gradient(to right, #1a2a6c, #b21f1f, #fdbb2d)',
      tagCommon: 'background:rgb(159 135 207)'
    })
    const appStore = useAppStore()
    return {
      ...toRefs(reactiveData),
      handleErrorFriendAvatar,
      websiteConfig: computed(() => {
        return appStore.websiteConfig
      })
    }
  }
})
</script>

<style scoped>
.friends-item {
    margin: 2px 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: calc(320px / 2 - 6px);
}

.player {
    position: relative;
    z-index: 3;
    width: 100%;
    height: 130px;
    border-radius: 8px;
}

.player-content {
    position: relative;
    height: 100%;
    border-radius: 8px;
    z-index: 2;
}

.player-content:before {
    content: "";
    background-image: url(@/assets/purple-line.svg);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    width: 100%;
    height: 100%;
    position: absolute;
    border-radius: 8px;
}

.friend-tag {
    position: absolute;
    padding: 0 4px;
    border-radius: 8px 0 8px 0;
    color: #fff;
    font-size: 12px;
}

.player-bg {
    position: absolute;
    top: -14px;
    right: -2px;
    z-index: -1;
}

.player-bg img {
    width: 110px;
}

.album-cover {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    position: absolute;
    top: 26px;
    left: 10px;
    overflow: hidden;
    transition: 0.3s ease;
}

.album-cover::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: url('') center / cover;
    animation: rotate 15s linear infinite paused;
}

.player-content:hover .album-cover::before {
    animation-play-state: running;
}

.album-cover a {
    opacity: 1;
}

.album-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    padding: 4px;
    border-radius: 50%;
}

.play-controls-name {
    position: absolute;
    top: 34px;
    left: 68px;
    width: calc(100% - 80px);
}

.play-controls-name > a {
    opacity: 1;
}

.play-controls-name h4 {
    border: none;
    margin-top: -0.14285714em;
    padding: 0 0;
    font-family: Lato, 'Helvetica Neue', Arial, Helvetica, sans-serif;
    font-weight: 700;
    line-height: 1.28571429em;
    text-transform: none;
    color: rgba(255, 255, 255, 0.9);
}
.friend-name{
    font-size: 1rem;
}
.play-controls-time {
    position: absolute;
    font-size: .875rem;
    top: 56px;
    left: 68px;
}

.join-time {
    margin: 0 0 1em;
    line-height: 1.4285em;
    color: var(--background-secondary);
}

.play-controls-introduction {
    position: absolute;
    top: 92px;
    margin: 0 14px;
    max-width: calc(100% - 28px);
    color: var(--background-secondary);
}

.friend-desc {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    text-transform: capitalize;
    margin: 0 0 1em;
    line-height: 1.4285em;
}
.player::after{
    content: "" attr(id) "";
    position: absolute;
    right: 0.25rem;
    top: 0.5rem;
    opacity: .35;
    letter-spacing: 4px;
    writing-mode: tb-rl;
    text-transform: uppercase;
    font-size: var(--font-size-small);
    height: 7rem;
    line-height: 1.5;
    background: rgb(var(--color-sub-rgb) / .1);
    color: #fff;
    border-radius: 0 1em;
    z-index: 9;
}
</style>
